package com.zany.children.dao;

import com.zany.children.vo.ChargesOwed;
import com.zany.children.vo.PaymentProject;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import java.util.List;
import java.util.Map;

public class ChargesOwedDaoImpl extends SqlMapClientDaoSupport implements ChargesOwedDao {
    private SqlMapClientTemplate sqlMapClientTemplate = getSqlMapClientTemplate();

    @Override
    public Long saveChargesOwed(ChargesOwed chargesOwed) {
        Long id = (Long)sqlMapClientTemplate.insert("chargesowed.saveChargesOwed", chargesOwed);
        return id;
    }

    @Override
    public void updateChargesOwed(ChargesOwed chargesOwed) {
        sqlMapClientTemplate.update("chargesowed.updateChargesOwed",chargesOwed);
    }

    @Override
    public void deleteChargesOwedById(Long id) {
        sqlMapClientTemplate.update("chargesowed.deleteChargesOwedById",id);
    }

    @Override
    public List<ChargesOwed> getChargesOwedListPage(ChargesOwed chargesOwed) {
        List list = sqlMapClientTemplate.queryForList("chargesowed.getChargesOwedListPage", chargesOwed);
        return list;
    }

    @Override
    public Integer getChargesOwedListPageCount(ChargesOwed chargesOwed) {
        Integer count = (Integer) sqlMapClientTemplate.queryForObject("chargesowed.getChargesOwedListPageCount", chargesOwed);
        return count;
    }

    @Override
    public ChargesOwed getChargesOwedById(Long id) {
        ChargesOwed chargesOwed =(ChargesOwed) sqlMapClientTemplate.queryForObject("chargesowed.getChargesOwedById", id);
        return chargesOwed;
    }


    @Override
    public List<PaymentProject> getOwedPaymentProjectByClassId(Long classId) {
        List list = sqlMapClientTemplate.queryForList("chargesowed.getOwedPaymentProjectByClassId", classId);
        return list;
    }

    @Override
    public void updateChargesOwedMoney(Map<String,Object> param) {
        sqlMapClientTemplate.update("chargesowed.updateChargesOwedMoney",param);
    }
}
